package com.example.server;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.TextArea;
import javafx.scene.text.Text;

import java.io.IOException;

public class ServerController {

    @FXML
    private TextArea message;
    @FXML
    private Text msg; //服务器状态

    public static Thread thread = new Thread();

    @FXML
    public void initialize(){
        thread = new Thread(new MyServer(message));
    }

    @FXML
    public void start(ActionEvent actionEvent) {
        msg.setText("服务已启动");
        //启动server线程
        thread.start();
    }
    @FXML
    public void close(ActionEvent actionEvent) throws InterruptedException {
        msg.setText("服务已关闭");
        //关闭服务
        Thread.sleep(2000);
        thread.interrupt();

        //System.exit(1);
    }

    public void onServerLogButtonClick(ActionEvent actionEvent) throws IOException {

        ServerLog serverLog = new ServerLog();
        serverLog.showAllData();

    }
}
